import json
import matplotlib.pyplot as plt

# Load the data from the JSON file
with open('data.json', 'r') as file:
    data = json.load(file)

# Extract the temp_at_x and u_real data
temp_at_x = float(data['temp_at_x'])
u_real = float(data['u_real'])
ts = float(data['ts'])

diff = []

for i in range(len(temp_at_x)):
    df = temp_at_x[i] - u_real[i]
    if df < 1:
        df *= -1
    diff.append((100*df)/temp_at_x[i])

# Plotting temperature vs time at the fixed point
plt.figure()
plt.plot(ts, diff, label='Temperature at Fixed Point')
plt.xlabel('Time')
plt.ylabel('Temperature')
plt.title('Temperature vs Time at Fixed Point')
plt.legend()
plt.show()